<div style="width:100%; border:1px solid #efefef; margin-top:-1px; background:#f6f4f5; min-height:600px; ">
	<div class="container">
		<h1>Profil</h1>
		<?
		echo form_open('main/profile_save','',array('email'=>$email));
		
		echo validation_errors();
		
		echo "<label> Email: </label>";
		echo $email; 
		echo "<br />";
		
		echo "<label for='pass'> Parola: </label>";
		echo form_password('pass');
		echo "<br />";
		
		echo "<label for='cpass'> Confirma parola: </label>";
		echo form_password('cpass');
		echo "<br />";
		
		echo "<label for='car_no'> Nr. auto: </label>";
		echo form_input('car_no', $car_no);
		echo "<br />";
		
		echo "<label>&nbsp;</label>";
		echo form_submit('submit','Actualizare');
		
		echo form_close();
		
		?>
		
		<h2>Autorizatii</h2>
		<?php 
		if(count($auth)==0) {
			echo '<span class="warning">In acest moment nu aveti autorizatii de parcare inregistrate!</span>';
		} else {
			echo '<table width="100%" cellspacing="2" style="background:#fff; border: 1px solid #CCC;">';
			echo '<tr style="background-color: #efefef; height: 20px;"><td><b>Numar</b></td><td><b>Expira</b></td><td><b>Disponibilitate</b></td><td></td></tr>';
			foreach($auth as $row) {
				echo '<tr>';
				echo '<td>'.$row['auth_no'].'</td>';
				echo '<td>'.$row['valability'].'</td>';
				if($row['start_hour']==$row['end_hour'] || $row['start_hour']=='' || $row['end_hour']=='') {
					echo '<td>nonstop</td>';
				} else {
					echo '<td>'.$row['start_hour'].':00 - '.$row['end_hour'].':00</td>';
				}
				echo '<td>detalii | edit | sterge</td>';
				echo '</tr>';
			}
			echo '</table>';
		}
		?>
		
		<p>Puteti sa va adaugati autorizatia de parcare obtinuta de la primarie precum si datele cu privire le disponibilitatea acesteia folosind formularul de mai jos:</p>
		<div style="float:right">
		
			<div class="search_address">
	
				<label for="search_address">Cauta o adresa:</label>
				<input type="text" name="search_address" id="search_address" />
				<input type="button" name="submit" value="Cauta" onclick="gmapSearchAddress()" />
				<div class="help">Format: <em># Nume Strada, City, Country</em>, unde # = numarul strazii</div>
			</div>
			<div class="gmap">
				
				<div id="map_canvas"></div>
				
			</div>
			
			<div id="markerStatus"><i>Apasati pe harta si pozitionati marker-ul.</i></div>
		    <strong>Adresa cea mai apropiata:</strong>
		    <div id="address"></div>
		</div>
		<?
	
		echo  form_open_multipart('main/auth_save','',array('uid'=>$id,'utype'=>$user_type));
		
		echo validation_errors();
		
		echo "<label> Numar autorizatie: </label>";
		echo form_input('auth_no', $this->input->post('auth_no')); 
		echo "<br />";
	?>
		<script>
		$(function() {
			$( "#datepicker" ).datepicker();
			$( "#datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
		});
		</script>
		<input type="hidden" name="lat" id="lat">
		<input type="hidden" name="long" id="long">
	<?php 
		$data = array(
					'name'=>'valability',
					'id' => 'datepicker'
				);
		if($user_type==0) {
			echo "<label for='valability'> Expira la: </label>";
			echo form_input($data);
			echo "<br />";
		}
		
		if($user_type==1) {
			echo "<label for='total'> Numar locuri: </label>";
			echo form_input('total');
			echo "<br />";
		}
		
		echo "<label for='file'> Poza: </label>";
		echo "<input type='file' name='userfile' size='20' />";
		echo "<br />";
		
		$hours = array("");
		for($i=0;$i<25;$i++) {
			if($i<10) 
				$hours['0'.$i] = '0'.$i;
			else
				$hours[$i] = $i;
		}
		
		echo "<label for='ora_start'> De la ora: </label>";
		echo form_dropdown('ora_start', $hours,'00');
		echo "<br />";
		
		echo "<label for='ora_end'> La ora: </label>";
		echo form_dropdown('ora_end', $hours,'00');
		echo "<br />";
		
		echo "<label>&nbsp;</label>";
		echo form_submit('submit','Adaugare');
		
		echo form_close();
		?>
		<style>
		.gmap { width:400px; height:200px; }
		#map_canvas { width:400px; height:200px; }
		</style>
		<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var initialLocation;

var map;
var marker;
var latLng=null;

var contentString = 'Autorizatia ta';
var infowindow;

infowindow = new google.maps.InfoWindow({
	content: contentString
});

var current_address;

var geocoder = new google.maps.Geocoder();

var GeocoderStatusDescription = {
  "OK": "The request did not encounter any errors",
  "UNKNOWN_ERROR": "A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known",
  "OVER_QUERY_LIMIT": "The webpage has gone over the requests limit in too short a period of time",
  "REQUEST_DENIED": "The webpage is not allowed to use the geocoder for some reason",
  "INVALID_REQUEST": "This request was invalid",
  "ZERO_RESULTS": "The request did not encounter any errors but returns zero results",
  "ERROR": "There was a problem contacting the Google servers"
};

var GeocoderLocationTypeDescription = {
  "ROOFTOP": "The returned result reflects a precise geocode.",
  "RANGE_INTERPOLATED": "The returned result reflects an approximation (usually on a road) interpolated between two precise points (such as intersections). Interpolated results are generally returned when rooftop geocodes are unavilable for a street address.",
  "GEOMETRIC_CENTER": "The returned result is the geometric center of a result such a line (e.g. street) or polygon (region).",
  "APPROXIMATE": "The returned result is approximate."
}



function instanceOf(object, constructorFunction) {
  while (object != null) {
    if (object == constructorFunction.prototype)
     {return true}
    object = object.__proto__;
  }
  return false;
}


function geocodePosition(pos) {
  geocoder.geocode({
    latLng: pos
  }, function(responses) {
    if (responses && responses.length > 0) {
      updateMarkerAddress(responses[0].formatted_address);
      current_address = responses[0].formatted_address;
    } else {
      updateMarkerAddress('Cannot determine address at this location.');
      current_address = '';
    }
  });
}

function updateMarkerStatus(str) {
  document.getElementById('markerStatus').innerHTML = str;
}


function updateMarkerPositionInfo(latLng) {
  jQuery('input#lat').val(latLng.lat());
  jQuery('input#long').val(latLng.lng());
}

function updateMarkerAddress(str) {
  document.getElementById('address').innerHTML = str;
}

function updateMarkerPosition(event)
{
	if (marker)
	{
		marker.setPosition(event.latLng);
		updateMarkerPositionInfo(marker.getPosition());
		geocodePosition(marker.getPosition());
	}	
}

document.getElementById('search_address').onkeyup = function(e) {
	if (!e) var e = window.event;
	if (e.keyCode == 13)
	{
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
			document.execCommand('Stop');
		window.stop();
		document.getElementById('search_address').blur();
		gmapSearchAddress();
		return false;
	}
}
  
function gmapSearchAddress()
{
	str=document.getElementById('search_address').value;
	if (str.length>0)
	{
		if (geocoder) {
			geocoder.geocode( { 'address': str }, function(results, status) {
				showResults(results, status);
			});
		}
	}	
	return false;
}

function showResults(results, result_status)
{
    if (result_status == google.maps.GeocoderStatus.OK) {
		updateMarkerAddress(results[0].formatted_address);
		latLng = results[0].geometry.location;
		var myOptions = {
			zoom: 17,
			center: latLng,
			mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		
		map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
		// Update current position info.
		updateMarkerPositionInfo(latLng);
		geocodePosition(latLng);
		marker = new google.maps.Marker({
              map: map, 
              position: results[0].geometry.location,
              draggable: true
          });
		
		google.maps.event.addListener(marker, 'click', function() {
			infowindow.open(map, marker);
		});
         
		google.maps.event.addListener(marker, 'dragstart', function() {
			updateMarkerAddress('Pozitionare...');
		});
		
		google.maps.event.addListener(marker, 'drag', function() {
			updateMarkerStatus('Pozitionare...');
			updateMarkerPositionInfo(marker.getPosition());
		});
		
		google.maps.event.addListener(marker, 'dragend', function() {
			updateMarkerStatus('');
			geocodePosition(marker.getPosition());
		});
		
		google.maps.event.addListener(map, 'click', updateMarkerPosition);
		
	} else {
	  updateMarkerAddress("Geocode was not successful for the following reason: " + GeocoderStatusDescription[result_status]);
	}
}

function initialize() {

	var str = 'Bucharest, Romania';
	var editLatLng;
	var editLat='44.4392036';
	var editLng='26.08265879999999';
	
	if (editLat && editLng)
	{
		editLatLng=new google.maps.LatLng(editLat, editLng);         
	}
	
	if (editLatLng && instanceOf(editLatLng, google.maps.LatLng))
	{
	     if (geocoder) {
			
			geocoder.geocode( { 'latLng': editLatLng }, function(results, status) {
				showResults(results, status);
			});
			
		}       
	}
	else
	{
		if (geocoder) {
			
			geocoder.geocode( { 'address': str }, function(results, status) {
				showResults(results, status);
			});
			
		}
	}
	

}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
	</div>
</div>